using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DataHelper.BLL
{
    public class webpages_Membership
    {
        public int UserId { get; set; }
        public DateTime CreateDate { get; set; }
        public string ConfirmationToken { get; set; }
        public bool IsConfirmed { get; set; }
        public DateTime LastPasswordFailureDate { get; set; }
        public int PasswordFailuresSinceLastSuccess { get; set; }
        public string Password { get; set; }
        public DateTime PasswordChangedDate { get; set; }
        public string PasswordSalt { get; set; }
        public string PasswordVerificationToken { get; set; }
        public DateTime PasswordVerificationTokenExpirationDate { get; set; }

        #region webpages_MembershipSelectAll
        public static List<webpages_Membership> webpages_MembershipSelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.webpages_Membership.webpages_MembershipSelectAll(strSearch,top,bottom,ConnectionString);
            List<webpages_Membership> webpages_MembershipList = new List<webpages_Membership>();
            while(dr.Read())
            {
                webpages_Membership mywebpages_Membership = new webpages_Membership
                {
                    UserId = !dr.IsDBNull(dr.GetOrdinal("UserId")) ? (int)dr["UserId"] : 0,
                    CreateDate = !dr.IsDBNull(dr.GetOrdinal("CreateDate")) ? (DateTime)dr["CreateDate"] : DateTime.Now,
                    ConfirmationToken = !dr.IsDBNull(dr.GetOrdinal("ConfirmationToken")) ? (string)dr["ConfirmationToken"] : null,
                    IsConfirmed = !dr.IsDBNull(dr.GetOrdinal("IsConfirmed")) ? (bool)dr["IsConfirmed"] : false,
                    LastPasswordFailureDate = !dr.IsDBNull(dr.GetOrdinal("LastPasswordFailureDate")) ? (DateTime)dr["LastPasswordFailureDate"] : DateTime.Now,
                    PasswordFailuresSinceLastSuccess = !dr.IsDBNull(dr.GetOrdinal("PasswordFailuresSinceLastSuccess")) ? (int)dr["PasswordFailuresSinceLastSuccess"] : 0,
                    Password = !dr.IsDBNull(dr.GetOrdinal("Password")) ? (string)dr["Password"] : null,
                    PasswordChangedDate = !dr.IsDBNull(dr.GetOrdinal("PasswordChangedDate")) ? (DateTime)dr["PasswordChangedDate"] : DateTime.Now,
                    PasswordSalt = !dr.IsDBNull(dr.GetOrdinal("PasswordSalt")) ? (string)dr["PasswordSalt"] : null,
                    PasswordVerificationToken = !dr.IsDBNull(dr.GetOrdinal("PasswordVerificationToken")) ? (string)dr["PasswordVerificationToken"] : null,
                    PasswordVerificationTokenExpirationDate = !dr.IsDBNull(dr.GetOrdinal("PasswordVerificationTokenExpirationDate")) ? (DateTime)dr["PasswordVerificationTokenExpirationDate"] : DateTime.Now
                };
                webpages_MembershipList.Add(mywebpages_Membership);
        }
        dr.Close();
        dr.Dispose();
        return webpages_MembershipList;
        }
        #endregion
        #region webpages_MembershipSelectRow
        public static webpages_Membership webpages_MembershipSelectRow(int UserId, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.webpages_Membership.webpages_MembershipSelectRow(UserId, ConnectionString);
            webpages_Membership webpages_membership = null;

            if(dr.Read())
            {
                webpages_membership= new webpages_Membership
                {
                    UserId = !dr.IsDBNull(dr.GetOrdinal("UserId")) ? (int)dr["UserId"] : 0,
                    CreateDate = !dr.IsDBNull(dr.GetOrdinal("CreateDate")) ? (DateTime)dr["CreateDate"] : DateTime.Now,
                    ConfirmationToken = !dr.IsDBNull(dr.GetOrdinal("ConfirmationToken")) ? (string)dr["ConfirmationToken"] : null,
                    IsConfirmed = !dr.IsDBNull(dr.GetOrdinal("IsConfirmed")) ? (bool)dr["IsConfirmed"] : false,
                    LastPasswordFailureDate = !dr.IsDBNull(dr.GetOrdinal("LastPasswordFailureDate")) ? (DateTime)dr["LastPasswordFailureDate"] : DateTime.Now,
                    PasswordFailuresSinceLastSuccess = !dr.IsDBNull(dr.GetOrdinal("PasswordFailuresSinceLastSuccess")) ? (int)dr["PasswordFailuresSinceLastSuccess"] : 0,
                    Password = !dr.IsDBNull(dr.GetOrdinal("Password")) ? (string)dr["Password"] : null,
                    PasswordChangedDate = !dr.IsDBNull(dr.GetOrdinal("PasswordChangedDate")) ? (DateTime)dr["PasswordChangedDate"] : DateTime.Now,
                    PasswordSalt = !dr.IsDBNull(dr.GetOrdinal("PasswordSalt")) ? (string)dr["PasswordSalt"] : null,
                    PasswordVerificationToken = !dr.IsDBNull(dr.GetOrdinal("PasswordVerificationToken")) ? (string)dr["PasswordVerificationToken"] : null,
                    PasswordVerificationTokenExpirationDate = !dr.IsDBNull(dr.GetOrdinal("PasswordVerificationTokenExpirationDate")) ? (DateTime)dr["PasswordVerificationTokenExpirationDate"] : DateTime.Now,

                };
            }
        dr.Close();
        dr.Dispose();
        return webpages_membership;
        }
        #endregion
        #region webpages_MembershipInsertRow
        public static void webpages_MembershipInsertRow(int UserId, DateTime CreateDate, string ConfirmationToken, bool IsConfirmed, DateTime LastPasswordFailureDate, int PasswordFailuresSinceLastSuccess, string Password, DateTime PasswordChangedDate, string PasswordSalt, string PasswordVerificationToken, DateTime PasswordVerificationTokenExpirationDate, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.webpages_Membership.webpages_MembershipInsertRow(UserId, CreateDate, ConfirmationToken, IsConfirmed, LastPasswordFailureDate, PasswordFailuresSinceLastSuccess, Password, PasswordChangedDate, PasswordSalt, PasswordVerificationToken, PasswordVerificationTokenExpirationDate, ConnectionString);
        }
        #endregion
        #region webpages_MembershipUpdateRow
        public static void webpages_MembershipUpdateRow(int UserId, DateTime CreateDate, string ConfirmationToken, bool IsConfirmed, DateTime LastPasswordFailureDate, int PasswordFailuresSinceLastSuccess, string Password, DateTime PasswordChangedDate, string PasswordSalt, string PasswordVerificationToken, DateTime PasswordVerificationTokenExpirationDate, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.webpages_Membership.webpages_MembershipUpdateRow(UserId, CreateDate, ConfirmationToken, IsConfirmed, LastPasswordFailureDate, PasswordFailuresSinceLastSuccess, Password, PasswordChangedDate, PasswordSalt, PasswordVerificationToken, PasswordVerificationTokenExpirationDate, ConnectionString);
        }
        #endregion
        #region webpages_MembershipDeleteRow
        public static void webpages_MembershipDeleteRow(int UserId, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.webpages_Membership.webpages_MembershipDeleteRow(UserId,ConnectionString);
        }
        #endregion
    }
}
